<template>
	<el-container>
		<el-main class="nopadding" style="padding: 30px;">
			<el-card class="box-card" style="margin-top: 20px;">
				<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px">
					<el-form-item label="小程序转网址" prop="page">
						<el-input v-model="form.page" placeholder="请输入小程序页面地址" style="width: 300px;" clearable></el-input>
					</el-form-item>
				</el-form>
				<el-button type="primary" :loading="isSaveing" @click="submit()">确定</el-button>
				<div style="margin-top: 20px;">
					<el-link type="success" v-copy="url_link" v-if="url_link">{{url_link}}</el-link>
				</div>
			</el-card>

		</el-main>
	</el-container>
</template>

<script>
	export default {
		name: 'orderList',
		components: {},
		data() {
			return {
				form: {
					page: '',
				},
				isSaveing: false,
				url_link: '',
				//验证规则
				rules: {
				},
			}
		},
		computed: {},
		mounted() {},
		methods: {
			//表单提交方法
			async submit() {
				let valid = await this.$refs.dialogForm.validate().catch(() => {})
				if (!valid) {
					return false
				}
				this.isSaveing = true;
				let res = await this.$API.marketing.tools.pageToUrl.get(this.form);
				this.isSaveing = false;
				if (res.code == 200) {
					if (res.data.errcode != 0) {
						this.$alert(res.data.errmsg, "提示", {
							type: 'error'
						})
						return
					}
					this.url_link = res.data.url_link
				} else {
					this.$alert(res.msg, "提示", {
						type: 'error'
					})
				}
			},
		}
	}
</script>

<style lang="scss">
</style>
